package day09API.stream;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author DBX
 * @date 2021/8/26 0026 - 20:55
 */
public class FileReaderTest {



    public static void main(String[] args) {
        FileReader fr = null;
        FileWriter fw = null;
        try {
            fr = new FileReader("./File/fos.txt");
            fw = new FileWriter("./File/fw.txt",true);
            char[] c = new char[4];
            int readCount = 0;
            while ((readCount = fr.read(c))!=-1){
                System.out.println(1);
                fw.write(c,0,readCount);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (fr != null) {
                try {
                    fr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            if (fw != null) {
                try {
                    fw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
